import matplotlib.pyplot as plt  
import numpy as np

f = open("dataE.txt","r")
n = int(f.readline())
v = list(map(float,f.readline().split()))
lt=[]
lx=[]
ly=[]
content = f.readlines()
for i in range(0,n-1):
    c = list(map(float,content[2*i].split()))
    d = list(map(float,content[2*i+1].split()))
    t = np.linspace(v[i],v[i+1],100)
    if len(c) == 4:
        x = c[0]*t**3+c[1]*t**2+c[2]*t+c[3]
        y = d[0]*t**3+d[1]*t**2+d[2]*t+d[3]
    else:
        x = c[0]*t+c[1]
        y = d[0]*t+d[1]
    lt.extend(t)
    lx.extend(x)
    ly.extend(y)
plt.plot(lx,ly,label='complete')
#plt.plot(lx,ly,label='specified second derivatives')
#plt.plot(lx,ly,label='natural')

plt.legend()
plt.show()
f.close()